package com.da.javatest.leetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenlida
 * @date 2019/1/8 14:17
 * @description
 */
public class Code144 {
    private List<Integer> result = new ArrayList<>();

    public List<Integer> preorderTraversal(TreeNode root) {
        getNode(root);
        return result;
    }

    private void getNode(TreeNode node) {
        if (node != null) {
            result.add(node.val);
            getNode(node.left);
            getNode(node.right);
        }
    }
}
